package com.itheima.demo;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class MapDemo {

    public static void main(String[] args) {

        Map<String , String> map = new HashMap<>();

        map.put("zhangsan","lisi");
        map.put("dingyi","chener");
        map.put("wangwu","zhaoliu");


        //根据键找值
        /*for (String a : map.keySet()){

            String s = map.get(a);
            System.out.println(a+"   "+s);
        }*/


        //根据键值对对象遍历
        /*Set<Map.Entry<String, String>> entries = map.entrySet();
        for(Map.Entry<String, String> a : entries){
            String key = a.getKey();
            String value = a.getValue();
            System.out.println(key+"----"+value);
        }*/


        //forEach

        map.forEach((s, s2) -> System.out.println(s+"- - - "+s2));
    }
}
